﻿using System;
using System.Collections.Generic;
using System.Text;
using OneMG.Phoenix.Service.Contracts;
using OneMG.Phoenix.Service.Model;
using OneMG.Phoenix.IBatisRepository;
using OneMG.Phoenix.Respository;
using System.Data;
using OneMG.Phoenix.Entity;

namespace OneMG.Phoenix.Service
{
    public class AdminUserGroupService : IAdminUserGroupService
    {
		 IAdminUserGroup adminUserGroup = new AdminUserGroupRepository();
		 
        public System.Int32 AddAdminUserGroup(AdminUserGroupModel model)
        {
			EAdminUserGroup entity = ConvertModelToEntity(model);
			
            return adminUserGroup.AddAdminUserGroup(entity);
        }

		public void UpdateByAdminUserGroupID (AdminUserGroupModel model)
		{
			EAdminUserGroup entity = ConvertModelToEntity(model);

            adminUserGroup.UpdateByAdminUserGroupID(entity);

		}

		public void DeleteByAdminUserGroupID (System.Int32 adminUserGroupID)
		{
		
            adminUserGroup.DeleteByAdminUserGroupID(adminUserGroupID);

		}
		 
        public AdminUserGroupModel GetByAdminUserGroupID (System.Int32 adminUserGroupID)
        {
        
			EAdminUserGroup entity = adminUserGroup.GetByAdminUserGroupID(adminUserGroupID);
			
            AdminUserGroupModel model = ConvertEntityToModel(entity);


            return model;
        }
        
		public AdminUserGroupModel ConvertEntityToModel(EAdminUserGroup entity)
		{
			if (entity == null)
            {
                return null;
            }
			AdminUserGroupModel model = new AdminUserGroupModel();
                        model.AdminUserGroupID = entity.AdminUserGroupID;
                        model.UserID = entity.UserID;
                        model.GroupID = entity.GroupID;
                        return model;
		}
		
		public EAdminUserGroup ConvertModelToEntity(AdminUserGroupModel model)
		{
			if (model == null)
            {
                return null;
            }
			EAdminUserGroup entity = new EAdminUserGroup();
                        entity.AdminUserGroupID = model.AdminUserGroupID;
                        entity.UserID = model.UserID;
                        entity.GroupID = model.GroupID;
                        return entity;
		}
    }
}